﻿Public Class dsTranDau
    Dim ctx As New QLDBDataContext
    Private _matran As Integer
    Private _capdau As String


    Sub New()
        _matran = -1
        _capdau = ""
    End Sub
    Public Property MaTran As Integer
        Get
            Return _matran
        End Get
        Set(value As Integer)
            _matran = value
        End Set
    End Property


    Public Property CapDau As String
        Get
            Return _capdau
        End Get
        Set(value As String)
            _capdau = value
        End Set
    End Property

    Overridable Function LayTenDoi(ByVal MD As Integer) As String
        Dim v = ctx.CAULACBOs.SingleOrDefault(Function(p) p.MaCLB = MD)
        Return v.TenCLB
    End Function
    Public Overridable Function LayCapDau(ByVal _vong As Integer) As List(Of dsTranDau)
        Dim v = From q In ctx.TRANDAUs Where q.Vong = _vong
                Select New dsTranDau With {.MaTran = q.MaTran, ._capdau = String.Format("{0} vs {1}", LayTenDoi(q.MaCLB1), LayTenDoi(q.MaCLB2))}
        Return v.ToList()
    End Function
    Public Function LayLink(ByVal index As Integer) As String
        Dim query = (From p In ctx.TRANDAUs
                    Where p.MaTran = index
                    Select p.video).First()

        Return query
    End Function
End Class
